<!-- 好像没用到 -->
<template>
  <el-dialog title="生成委外订单" :close-on-click-modal="false" :visible.sync="visible" center fullscreen>
    <el-button class="miui-dialog-close-btn" @click="visible = false">关闭页面</el-button>
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      <el-row :gutter="15">
        <el-col :span="8">
          <el-form-item label="制造商" prop="outDeptId">
            <el-select v-model="dataForm.outDeptId" placeholder="请选择" disabled>
              <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="订单类型" prop="inDeptId">
            <el-select v-model="dataForm.inDeptId" placeholder="请选择" disabled>
              <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货单号" prop="inDeptId">
            <el-select v-model="dataForm.inDeptId" placeholder="请选择" disabled>
              <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="收货联系人" prop="outDeptId">
            <el-select v-model="dataForm.outDeptId" placeholder="请选择" disabled>
              <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货联系电话" prop="inDeptId">
            <el-select v-model="dataForm.inDeptId" placeholder="请选择" disabled>
              <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="收货联系传真" prop="inDeptId">
            <el-select v-model="dataForm.inDeptId" placeholder="请选择" disabled>
              <el-option v-for="item in deptOptions" :key="item.value" :label="item.name" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="收货地址" prop="inDeptId">
            <el-input type="textarea" disabled></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="备注" prop="inDeptId">
            <el-input type="textarea" disabled></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55"></el-table-column>
      <el-table-column prop="goodsBarcode" label="配镜单号"></el-table-column>
      <el-table-column prop="goodsName" label="取镜时间"></el-table-column>
      <el-table-column prop="spec" label="商品名称"></el-table-column>
      <el-table-column label="委外方式">
        <template slot-scope="scope">
          <el-select v-model="scope.row.spec">
            <el-option value="1" label="委外订单"></el-option>
            <el-option value="2" label="委外加工"></el-option>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column prop="spec" label="镜片类型"></el-table-column>
      <el-table-column prop="spec" label="数量"></el-table-column>
      <el-table-column prop="spec" label="球镜"></el-table-column>
      <el-table-column prop="spec" label="柱镜"></el-table-column>
      <el-table-column prop="spec" label="轴向"></el-table-column>
      <el-table-column prop="spec" label="下加"></el-table-column>
      <el-table-column prop="applyQuantity" label="棱镜"></el-table-column>
      <el-table-column prop="applyQuantity" label="瞳高"></el-table-column>
      <el-table-column prop="applyQuantity" label="加工要求"></el-table-column>
      <el-table-column prop="applyQuantity" label="销售备注" show-overflow-tooltip></el-table-column>
    </el-table>
  </el-dialog>
</template>

<script>
    import {saveNewCheckOrder,saveAndAuditOrder,getStockDataList,getCtgDataList} from '@/api/eims/check'
    import {allocationApplyAdd,allocationApplyGetObj,allocationApplyEdit} from '@/api/eims/allocation-apply'
    import {fetchTree} from '@/api/admin/dept.js'
    export default {
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          applyStatus: '2',
          outDeptId: '',
          outDeptName: '',
          inDeptId: '',
          inDeptName: '',
          memo: '',
          detailList: []
        },
        deptOptions: [],
        dataList: [],
        dataListLoading: false,
        dataRule: {outDeptId: [{ required: true,message: '请选择申请部门'}],inDeptId: [{required:true,message: '请选择接收部门'}]},
        selectionList: [],
        receiveListVisible: false
      }
    },
    methods: {
      init (id) {
        this.getDeptList()
        this.dataForm.id = id || 0
        this.visible = true
        this.dataList = []
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            // allocationApplyGetObj(this.dataForm.id).then(result => {
            //   this.dataForm = result.data.data.data
            //   let goodsData = result.data.data.data.detailList
            //   this.dataList = goodsData
            //   for(let i = 0; i < this.dataList.length; i++){
            //     this.dataList[i].goodsBarcode = goodsData[i].barcode
            //     this.dataList[i].goodsName = goodsData[i].name
            //     this.dataList[i].spec = goodsData[i].spec
            //   }
            // })
          }
        })
      }
    }
  }
</script>
